from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.decorators.cache import cache_page
from mhlandscaping.apps.home.models import Layout
from mhlandscaping.apps.world.models import Map

import settings

@cache_page(settings.CACHE_LENGTH, key_prefix="home")
def home(request):
    layout = []
    map = []
    
    try:
        layout = Layout.objects.all()[:1][0]
    except Layout.DoesNotExist:
        pass
    
    try:
        map = Map.objects.all()[:1][0]
    except Map.DoesNotExist:
        pass

    return render_to_response('home/templates/home.html', 
                              {'layout': layout,
                               'map': map}, 
                              context_instance=RequestContext(request))